package com.wjb.xietong.ota.tab4;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wjb.xietong.R;
import com.wjb.xietong.ota.BaseOTA;


public class OTAAbout extends BaseOTA {

	private LinearLayout btn_careweibo;
	private LinearLayout btn_emailtous;
	private TextView version;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentField(getLayoutInflater().inflate(R.layout.page_more_about,
				null));

		setTopBarAndAction(getResources().getString(R.string.STR_SETTING_07),
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						app_.getActManager().popActivity();
					}
				}, null);

	}

	@Override
	protected void findView(View v) {
		super.findView(v);
		btn_careweibo = (LinearLayout) v.findViewById(R.id.btn_careweibo);
		btn_emailtous = (LinearLayout) v.findViewById(R.id.btn_emailtous);

		version = (TextView) v.findViewById(R.id.tv_version);
		version.setText(getVersion());
	}

	@Override
	protected void setOnClickEvent() {
		// TODO Auto-generated method stub
		super.setOnClickEvent();
		btn_careweibo.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				//do something
			}
		});

		btn_emailtous.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				//do something
			}
		});
	}

	private String getVersion() {
		try {
			PackageManager manager = this.getPackageManager();
			PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
			String version = info.versionName;
			return this.getString(R.string.STR_ABOUT_01) + " " + version;
		} catch (Exception e) {
			e.printStackTrace();
			return this.getString(R.string.STR_ABOUT_01) + " 0.0.0";
		}
	}
}
